#!/bin/bash

#--------------------------CONFIGURATIONS-----------------------------

num_threads=2

name_spec="GF-first"

queue="smnodes"
#queue="eca"

#------------------------END CONFIGURATIONS---------------------------

job_file="qsub_script_to_run_psi.sge"
job_name="PSI ${num_threads} thread(s)"
job_out="out-PSI-${name_spec}-N${num_threads}.txt"

cat > ${job_file} << EOF
#!/bin/bash
#$ -S /bin/bash

# Select the queue
#$ -q ${queue}
#$ -pe make ${num_threads}

# Set the job name
#$ -N "${job_name}"

# Set the output file and merge it to the sterr (-j y)
#$ -o ${job_out}
#$ -j y

# Start the job in the current directory
#$ -cwd

set -x
hostname
#ulimit -s unlimited
cd /home/marco/LDG-H/trunk/run
export OMP_NUM_THREADS=${num_threads}
date
./../bin/psi
date
EOF

# qsub appends the output, which can be confusing
if [ -e "${job_out}" ]
 then
  rm ${job_out}
fi

qsub ${job_file} && rm ${job_file}

